package com.xiaoma.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class DriverManagerTest {

  public static void main(String[] args) throws Exception {
//    Class.forName("com.mysql.cj.jdbc.Driver");
    //3.获取数据库连接对象
    Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test?serverTimezone=PRC", "root", "123456");
    //4.定义sql语句
    String sql = "select * from user";
    //5.获取执行sql的对象 Statement
    Statement stmt = conn.createStatement();
    //6.执行sql
    ResultSet resultSet = stmt.executeQuery(sql);
    //7.处理结果
    System.out.println(resultSet);
    //8.释放资源
    stmt.close();
    conn.close();
  }
}
